using Cola.Core.Skill.Utils;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Memory;

namespace Cola.Core.Skill;

public class KernelProvider : IKernelProvider {
    public IKernel GetKernel(ILogger<IKernel> logger) =>
        new KernelBuilder().WithLogger(logger).Configure(p => {
            p.AddAzureOpenAITextCompletionService(
                ProjectEnvironment.Get("AzureOpenAIServiceId"),
                ProjectEnvironment.Get("AzureOpenAIDeploymentName"),
                ProjectEnvironment.Get("AzureOpenAIEndpoint"),
                ProjectEnvironment.Get("AzureOpenAIKey"));

            p.AddAzureOpenAIEmbeddingGenerationService(
                ProjectEnvironment.Get("AzureOpenAIEmbeddingsServiceId"),
                ProjectEnvironment.Get("AzureOpenAIEmbeddingsDeploymentName"),
                ProjectEnvironment.Get("AzureOpenAIEmbeddingsEndpoint"),
                ProjectEnvironment.Get("AzureOpenAIEmbeddingsKey"));
        }).WithMemoryStorage(new VolatileMemoryStore()).Build();
}